package com.java.service;

import com.java.dao.Maker3Mapper;
import com.java.pojo.EnterGood;
import com.java.pojo.Maker3;
import com.java.pojo.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Maker3ServiceImpl implements Maker3Service {
    @Autowired
    private Maker3Mapper maker3Mapper;
    @Override
    public int addMaker3(Maker3 maker3) {
        return maker3Mapper.addMaker3(maker3);
    }

    @Override
    public Page<Maker3> getPageByPage1(Integer a, String forname) {
        int b=4;//显示条数
        Page<Maker3> page=new Page<>();
        page.setCurryPage(a);//设置当前页码
        page.setRows(b);//设置每页显示的条数
        Integer count = maker3Mapper.getCountMaker3(forname,1);//总条数
        page.setTotalCount(count);//总条数
        int start=(a-1)*b;/*开始的索引*/
        List<Maker3> list = maker3Mapper.getListMaker3(start, b, forname,1);
        page.setList(list);/*赋值list*/
        int totalPae=count % b==0 ? count / b : (count / b)+1;
        page.setTotalPae(totalPae);/*设置总页数*/
        if(page==null){
            page=null;
        }
        return page;
    }

    @Override
    public Integer getCount1(String forname) {
        return maker3Mapper.getCountMaker3(forname,1);
    }

    @Override
    public Page<Maker3> getPageByPage0(Integer a, String forname) {
        int b=4;//显示条数
        Page<Maker3> page=new Page<>();
        page.setCurryPage(a);//设置当前页码
        page.setRows(b);//设置每页显示的条数
        Integer count = maker3Mapper.getCountMaker3(forname,0);//总条数
        page.setTotalCount(count);//总条数
        int start=(a-1)*b;/*开始的索引*/
        List<Maker3> list = maker3Mapper.getListMaker3(start, b, forname,0);
        page.setList(list);/*赋值list*/
        int totalPae=count % b==0 ? count / b : (count / b)+1;
        page.setTotalPae(totalPae);/*设置总页数*/
        if(page==null){
            page=null;
        }
        return page;
    }

    @Override
    public Integer getCount0(String forname) {
        return maker3Mapper.getCountMaker3(forname,0);
    }

    @Override
    public int delMaker3(Integer id) {
        return maker3Mapper.delMaker3(id);
    }
}
